package com.ksu.manager.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ksu.manager.model.pages.Pagination;

public class PageQuery {

	@SuppressWarnings({ "rawtypes" })
	public static Map<String,Object> query(Pagination page,int sum,List list){
		page.setSum(sum);
		int i = sum%page.getPageNumber();
		if(i!=0){
		    page.setTotalPage(sum/page.getPageNumber() + 1);
		}else{
			page.setTotalPage(sum/page.getPageNumber());
		}

		if(page.getCurrentPage() == 0){
			page.setCurrentPage(1);
		}
		Map<String,Object> resultMap = new HashMap<String,Object>();
		resultMap.put("page", page);
		resultMap.put("list",list);
		return resultMap;
	}
}
